﻿using CacheAOP_Castle.AOPCache;

namespace CacheAOP_Castle.Service
{
    public interface IDateTimeService
    {
        string GetCurrentTime();
    }

    public class DateTimeService : IDateTimeService, ICaching
    {
        /// <summary>
        /// Castle的aop不能在接口上，只能在具体实现类上,aspectcore可以在接口上
        /// </summary>
        /// <returns></returns>
        [RedisCache(CacheKey = "timeInterface", Expiration = 10)]
        public string GetCurrentTime()
        {
            return System.DateTime.Now.ToString();
        }
    }
}
